home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
X User Tools
/
X User Tools (O'Reilly and Associates)(1994).ISO
/
sun4c
/
archive
/
tcltk.z
/
tcltk
/
man
/
catn
/
listbox.n
< prev
next >
Wrap
Text File
|
1994-09-20
|
12KB
|
331 lines
listbox(n) Tk Commands
_________________________________________________________________
NAME
listbox - Create and manipulate listbox widgets
SYNOPSIS
listbox _p_a_t_h_N_a_m_e ?_o_p_t_i_o_n_s?
STANDARD OPTIONS
background foreground selectBackgroundxScrollCommand |
borderWidth font selectBorderWidthyScrollCommand|
cursor geometry selectForeground |
exportSelection relief setGrid |
See the ``options'' manual entry for details on the standard
options.
WIDGET-SPECIFIC OPTIONS
None.
_________________________________________________________________
DESCRIPTION
The listbox command creates a new window (given by the _p_a_t_h_-
_N_a_m_e argument) and makes it into a listbox widget. Addi-
tional options, described above, may be specified on the
command line or in the option database to configure aspects
of the listbox such as its colors, font, text, and relief.
The listbox command returns its _p_a_t_h_N_a_m_e argument. At the
time this command is invoked, there must not exist a window
named _p_a_t_h_N_a_m_e, but _p_a_t_h_N_a_m_e's parent must exist.
A listbox is a widget that displays a list of strings, one
per line. When first created, a new listbox has no elements
in its list. Elements may be added or deleted using widget
commands described below. In addition, one or more elements
may be selected as described below. If a listbox is export- |
ing its selection (see exportSelection option), then it will |
observe the standard X11 protocols for handling the selec-
tion; listbox selections are available as type STRING, con-
sisting of a Tcl list with one entry for each selected ele-
ment.
For large lists only a subset of the list elements will be
displayed in the listbox window at once; commands described
below may be used to change the view in the window. List-
boxes allow scrolling in both directions using the standard |
xScrollCommand and yScrollCommand options. They also sup-
port scanning, as described below.
Tk 1
listbox(n) Tk Commands
WIDGET COMMAND
The listbox command creates a new Tcl command whose name is
_p_a_t_h_N_a_m_e. This command may be used to invoke various opera-
tions on the widget. It has the following general form:
_p_a_t_h_N_a_m_e _o_p_t_i_o_n ?_a_r_g _a_r_g ...?
_O_p_t_i_o_n and the _a_r_gs determine the exact behavior of the com-
mand. The following commands are possible for listbox widg-
ets:
_p_a_t_h_N_a_m_e configure ?_o_p_t_i_o_n? ?_v_a_l_u_e _o_p_t_i_o_n _v_a_l_u_e ...?
Query or modify the configuration options of the
widget. If no _o_p_t_i_o_n is specified, returns a list
describing all of the available options for _p_a_t_h_N_a_m_e
(see Tk_ConfigureInfo for information on the format of
this list). If _o_p_t_i_o_n is specified with no _v_a_l_u_e, then
the command returns a list describing the one named
option (this list will be identical to the correspond-
ing sublist of the value returned if no _o_p_t_i_o_n is
specified). If one or more _o_p_t_i_o_n-_v_a_l_u_e pairs are
specified, then the command modifies the given widget
option(s) to have the given value(s); in this case the
command returns an empty string. _O_p_t_i_o_n may have any
of the values accepted by the listbox command.
_p_a_t_h_N_a_m_e curselection
Returns a list containing the indices of all of the |
elements in the listbox that are currently selected. |
If there are no elements selected in the listbox then |
an empty string is returned.
_p_a_t_h_N_a_m_e delete _f_i_r_s_t ?_l_a_s_t?
Delete one or more elements of the listbox. _F_i_r_s_t and
_l_a_s_t give the integer indices of the first and last
elements in the range to be deleted. If _l_a_s_t isn't
specified it defaults to _f_i_r_s_t, i.e. a single element
is deleted. An index of 0 corresponds to the first
element in the listbox. Either _f_i_r_s_t or _l_a_s_t may be
specified as end, in which case it refers to the last
element of the listbox. This command returns an empty
string
_p_a_t_h_N_a_m_e get _i_n_d_e_x
Return the contents of the listbox element indicated by
_i_n_d_e_x. _I_n_d_e_x must be a non-negative integer (0
corresponds to the first element in the listbox), or it
may also be specified as end to indicate the last ele-
ment in the listbox.
_p_a_t_h_N_a_m_e insert _i_n_d_e_x ?_e_l_e_m_e_n_t _e_l_e_m_e_n_t ...?
Insert zero or more new elements in the list just
before the element given by _i_n_d_e_x. If _i_n_d_e_x is
Tk 2
listbox(n) Tk Commands
specified as end then the new elements are added to the
end of the list. Returns an empty string.
_p_a_t_h_N_a_m_e nearest _y
Given a y-coordinate within the listbox window, this
command returns the index of the (visible) listbox ele-
ment nearest to that y-coordinate.
_p_a_t_h_N_a_m_e scan _o_p_t_i_o_n _a_r_g_s
This command is used to implement scanning on list-
boxes. It has two forms, depending on _o_p_t_i_o_n:
_p_a_t_h_N_a_m_e scan mark _x _y
Records _x and _y and the current view in the list- |
box window; used in conjunction with later scan |
dragto commands. Typically this command is asso- |
ciated with a mouse button press in the widget. |
It returns an empty string. |
_p_a_t_h_N_a_m_e scan dragto _x _y. ||
This command computes the difference between its _x |
and _y arguments and the _x and _y arguments to the |
last scan mark command for the widget. It then |
adjusts the view by 10 times the difference in |
coordinates. This command is typically associated
with mouse motion events in the widget, to produce
the effect of dragging the list at high speed
through the window. The return value is an empty
string.
_p_a_t_h_N_a_m_e select _o_p_t_i_o_n _a_r_g
This command is used to adjust the selection within a
listbox. It has several forms, depending on _o_p_t_i_o_n.
In all of the forms the index end refers to the last
element in the listbox.
_p_a_t_h_N_a_m_e select adjust _i_n_d_e_x
Locate the end of the selection nearest to the
element given by _i_n_d_e_x, and adjust that end of the
selection to be at _i_n_d_e_x (i.e including but not
going beyond _i_n_d_e_x). The other end of the selec-
tion is made the anchor point for future select to
commands. If the selection isn't currently in the
listbox, then this command is identical to the
select from widget command. Returns an empty
string.
_p_a_t_h_N_a_m_e select clear
If the selection is in this listbox then it is |
cleared so that none of the listbox's elements are |
selected anymore.
Tk 3
listbox(n) Tk Commands
_p_a_t_h_N_a_m_e select from _i_n_d_e_x
Set the selection to consist of element _i_n_d_e_x, and
make _i_n_d_e_x the anchor point for future select to
widget commands. Returns an empty string.
_p_a_t_h_N_a_m_e select to _i_n_d_e_x
Set the selection to consist of the elements from
the anchor point to element _i_n_d_e_x, inclusive. The
anchor point is determined by the most recent
select from or select adjust command in this
widget. If the selection isn't in this widget,
this command is identical to select from. Returns
an empty string.
_p_a_t_h_N_a_m_e size
Returns a decimal string indicating the total number of
elements in the listbox.
_p_a_t_h_N_a_m_e xview _i_n_d_e_x
Adjust the view in the listbox so that character posi- |
tion _i_n_d_e_x is displayed at the left edge of the widget. |
Returns an empty string. |
_p_a_t_h_N_a_m_e yview _i_n_d_e_x ||
Adjust the view in the listbox so that element _i_n_d_e_x is |
displayed at the top of the widget. If _i_n_d_e_x is speci- |
fied as end it indicates the last element of the list- |
box. Returns an empty string.
DEFAULT BINDINGS
Tk automatically creates class bindings for listboxes that |
give them the following default behavior: |
[1] ||
When button 1 is pressed over a listbox, the element |
underneath the mouse cursor is selected. The mouse can |
be dragged to select a range of elements. |
[2] ||
The ends of the selection can be adjusted by dragging |
with mouse button 1 while the shift key is down; this |
will adjust the end of the selection that was nearest |
to the mouse cursor when button 1 was pressed. |
[3] ||
The view in the listbox can be adjusted by dragging |
with mouse button 2. |
The behavior of listboxes can be changed by defining new |
bindings for individual widgets or by redefining the class |
bindings. In addition, the procedure tk_listboxSingleSelect |
Tk 4
listbox(n) Tk Commands
may be invoked to change listbox behavior so that only a |
single element may be selected at once.
KEYWORDS
listbox, widget
Tk 5